package main.java;

/**
 * @author: 大怪
 * @email: 962527441@qq.com
 */
public class Test82_杨辉三角形问题 {
    public static int execute(int k, int i, int j) {
        // write code here
        if (k == 1){
            return 1;
        }
        int sum = 0;
        int[] relist = relist(k);
        for (i=i-1;i<j;i++){
            sum+=relist[i];
        }
        return sum;
    }

    public static int[] relist(int k){
        int[] arr = new int[k];
        arr[0]= 1;
        if (k==1){
            return arr;
        }
        int[] relist = relist(k - 1);
        for (int i = 1; i < k; i++) {
            if (i == k-1){
                arr[k-1] = 1;
            }else {
                arr[i]=relist[i-1]+relist[i];
            }
        }
        return arr;
    }
}
